/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INCLUDE_ARCH_IRQ_H
#define INCLUDE_ARCH_IRQ_H

#if !defined(ASSEMBLY)

#include "Std_Types.h"
#include <Compiler.h>
#ifdef CFG_USER_MODE_CASE
#include "switch_mode.h"
#endif /* #ifdef CFG_USER_MODE_CASE */
#define COMPILER_BARRIER() ASM volatile ("" ::: "memory")

/*
 * irq state type.
 */
typedef unsigned int  irq_state_t;
/*
 * is irq masked.
 *
 * @return   masked or not.
 */
boolean arch_irq_is_masked(void);

/*
 * is irq mode.
 *
 * @return   irq mode or not.
 */
boolean arch_in_irq_mode(void);

/**
 * @brief Enable vectored interrupt mode.
 */
void arch_vectored_irq_enable(boolean en);

/**
 * @brief Whether core is in FIQ mode or not
 *
 * @return true FIQ mode
 * @return false otherwise
 */
boolean arch_in_fiq_mode(void);
/*
 * cpsr irq si masked.
 *
 * @return  masked or not.
 */
boolean prev_irq_is_masked(uint32 cpsr);

/*
 * irq enable.
 */
void arch_irq_enable(void);

 /*
  * irq disable.
  */
void arch_irq_disable(void);

 /*
  * irq save.
  *
  * @return  old irq state.
  */
irq_state_t arch_irq_save(void);
 /*
  * irq restore.
  *
  * @flags   old irq state.
  */
void arch_irq_restore(irq_state_t flags);

#endif

#endif
